<?php


/**
 * Base class that represents a query for the 'team' table.
 *
 * 
 *
 * @method     TeamQuery orderByTeamid($order = Criteria::ASC) Order by the teamID column
 * @method     TeamQuery orderByNaam($order = Criteria::ASC) Order by the naam column
 * @method     TeamQuery orderByIcon($order = Criteria::ASC) Order by the icon column
 * @method     TeamQuery orderByPoulgroepid($order = Criteria::ASC) Order by the poulgroepID column
 *
 * @method     TeamQuery groupByTeamid() Group by the teamID column
 * @method     TeamQuery groupByNaam() Group by the naam column
 * @method     TeamQuery groupByIcon() Group by the icon column
 * @method     TeamQuery groupByPoulgroepid() Group by the poulgroepID column
 *
 * @method     TeamQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method     TeamQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method     TeamQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method     TeamQuery leftJoinPoulGroep($relationAlias = null) Adds a LEFT JOIN clause to the query using the PoulGroep relation
 * @method     TeamQuery rightJoinPoulGroep($relationAlias = null) Adds a RIGHT JOIN clause to the query using the PoulGroep relation
 * @method     TeamQuery innerJoinPoulGroep($relationAlias = null) Adds a INNER JOIN clause to the query using the PoulGroep relation
 *
 * @method     TeamQuery leftJoinWedstrijdRelatedByThuisteam($relationAlias = null) Adds a LEFT JOIN clause to the query using the WedstrijdRelatedByThuisteam relation
 * @method     TeamQuery rightJoinWedstrijdRelatedByThuisteam($relationAlias = null) Adds a RIGHT JOIN clause to the query using the WedstrijdRelatedByThuisteam relation
 * @method     TeamQuery innerJoinWedstrijdRelatedByThuisteam($relationAlias = null) Adds a INNER JOIN clause to the query using the WedstrijdRelatedByThuisteam relation
 *
 * @method     TeamQuery leftJoinWedstrijdRelatedByUitteam($relationAlias = null) Adds a LEFT JOIN clause to the query using the WedstrijdRelatedByUitteam relation
 * @method     TeamQuery rightJoinWedstrijdRelatedByUitteam($relationAlias = null) Adds a RIGHT JOIN clause to the query using the WedstrijdRelatedByUitteam relation
 * @method     TeamQuery innerJoinWedstrijdRelatedByUitteam($relationAlias = null) Adds a INNER JOIN clause to the query using the WedstrijdRelatedByUitteam relation
 *
 * @method     Team findOne(PropelPDO $con = null) Return the first Team matching the query
 * @method     Team findOneOrCreate(PropelPDO $con = null) Return the first Team matching the query, or a new Team object populated from the query conditions when no match is found
 *
 * @method     Team findOneByTeamid(int $teamID) Return the first Team filtered by the teamID column
 * @method     Team findOneByNaam(string $naam) Return the first Team filtered by the naam column
 * @method     Team findOneByIcon(string $icon) Return the first Team filtered by the icon column
 * @method     Team findOneByPoulgroepid(int $poulgroepID) Return the first Team filtered by the poulgroepID column
 *
 * @method     array findByTeamid(int $teamID) Return Team objects filtered by the teamID column
 * @method     array findByNaam(string $naam) Return Team objects filtered by the naam column
 * @method     array findByIcon(string $icon) Return Team objects filtered by the icon column
 * @method     array findByPoulgroepid(int $poulgroepID) Return Team objects filtered by the poulgroepID column
 *
 * @package    propel.generator.database.om
 */
abstract class BaseTeamQuery extends ModelCriteria
{

	/**
	 * Initializes internal state of BaseTeamQuery object.
	 *
	 * @param     string $dbName The dabase name
	 * @param     string $modelName The phpName of a model, e.g. 'Book'
	 * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
	 */
	public function __construct($dbName = 'database', $modelName = 'Team', $modelAlias = null)
	{
		parent::__construct($dbName, $modelName, $modelAlias);
	}

	/**
	 * Returns a new TeamQuery object.
	 *
	 * @param     string $modelAlias The alias of a model in the query
	 * @param     Criteria $criteria Optional Criteria to build the query from
	 *
	 * @return    TeamQuery
	 */
	public static function create($modelAlias = null, $criteria = null)
	{
		if ($criteria instanceof TeamQuery) {
			return $criteria;
		}
		$query = new TeamQuery();
		if (null !== $modelAlias) {
			$query->setModelAlias($modelAlias);
		}
		if ($criteria instanceof Criteria) {
			$query->mergeWith($criteria);
		}
		return $query;
	}

	/**
	 * Find object by primary key
	 * Use instance pooling to avoid a database query if the object exists
	 * <code>
	 * $obj  = $c->findPk(12, $con);
	 * </code>
	 * @param     mixed $key Primary key to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    Team|array|mixed the result, formatted by the current formatter
	 */
	public function findPk($key, $con = null)
	{
		if ((null !== ($obj = TeamPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
			// the object is alredy in the instance pool
			return $obj;
		} else {
			// the object has not been requested yet, or the formatter is not an object formatter
			$criteria = $this->isKeepQuery() ? clone $this : $this;
			$stmt = $criteria
				->filterByPrimaryKey($key)
				->getSelectStatement($con);
			return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
		}
	}

	/**
	 * Find objects by primary key
	 * <code>
	 * $objs = $c->findPks(array(12, 56, 832), $con);
	 * </code>
	 * @param     array $keys Primary keys to use for the query
	 * @param     PropelPDO $con an optional connection object
	 *
	 * @return    PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
	 */
	public function findPks($keys, $con = null)
	{	
		$criteria = $this->isKeepQuery() ? clone $this : $this;
		return $this
			->filterByPrimaryKeys($keys)
			->find($con);
	}

	/**
	 * Filter the query by primary key
	 *
	 * @param     mixed $key Primary key to use for the query
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKey($key)
	{
		return $this->addUsingAlias(TeamPeer::TEAMID, $key, Criteria::EQUAL);
	}

	/**
	 * Filter the query by a list of primary keys
	 *
	 * @param     array $keys The list of primary key to use for the query
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByPrimaryKeys($keys)
	{
		return $this->addUsingAlias(TeamPeer::TEAMID, $keys, Criteria::IN);
	}

	/**
	 * Filter the query on the teamID column
	 * 
	 * @param     int|array $teamid The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByTeamid($teamid = null, $comparison = null)
	{
		if (is_array($teamid) && null === $comparison) {
			$comparison = Criteria::IN;
		}
		return $this->addUsingAlias(TeamPeer::TEAMID, $teamid, $comparison);
	}

	/**
	 * Filter the query on the naam column
	 * 
	 * @param     string $naam The value to use as filter.
	 *            Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByNaam($naam = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($naam)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $naam)) {
				$naam = str_replace('*', '%', $naam);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(TeamPeer::NAAM, $naam, $comparison);
	}

	/**
	 * Filter the query on the icon column
	 * 
	 * @param     string $icon The value to use as filter.
	 *            Accepts wildcards (* and % trigger a LIKE)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByIcon($icon = null, $comparison = null)
	{
		if (null === $comparison) {
			if (is_array($icon)) {
				$comparison = Criteria::IN;
			} elseif (preg_match('/[\%\*]/', $icon)) {
				$icon = str_replace('*', '%', $icon);
				$comparison = Criteria::LIKE;
			}
		}
		return $this->addUsingAlias(TeamPeer::ICON, $icon, $comparison);
	}

	/**
	 * Filter the query on the poulgroepID column
	 * 
	 * @param     int|array $poulgroepid The value to use as filter.
	 *            Accepts an associative array('min' => $minValue, 'max' => $maxValue)
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByPoulgroepid($poulgroepid = null, $comparison = null)
	{
		if (is_array($poulgroepid)) {
			$useMinMax = false;
			if (isset($poulgroepid['min'])) {
				$this->addUsingAlias(TeamPeer::POULGROEPID, $poulgroepid['min'], Criteria::GREATER_EQUAL);
				$useMinMax = true;
			}
			if (isset($poulgroepid['max'])) {
				$this->addUsingAlias(TeamPeer::POULGROEPID, $poulgroepid['max'], Criteria::LESS_EQUAL);
				$useMinMax = true;
			}
			if ($useMinMax) {
				return $this;
			}
			if (null === $comparison) {
				$comparison = Criteria::IN;
			}
		}
		return $this->addUsingAlias(TeamPeer::POULGROEPID, $poulgroepid, $comparison);
	}

	/**
	 * Filter the query by a related PoulGroep object
	 *
	 * @param     PoulGroep $poulGroep  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByPoulGroep($poulGroep, $comparison = null)
	{
		return $this
			->addUsingAlias(TeamPeer::POULGROEPID, $poulGroep->getPoulgroepid(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the PoulGroep relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function joinPoulGroep($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('PoulGroep');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'PoulGroep');
		}
		
		return $this;
	}

	/**
	 * Use the PoulGroep relation PoulGroep object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    PoulGroepQuery A secondary query class using the current class as primary query
	 */
	public function usePoulGroepQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinPoulGroep($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'PoulGroep', 'PoulGroepQuery');
	}

	/**
	 * Filter the query by a related Wedstrijd object
	 *
	 * @param     Wedstrijd $wedstrijd  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByWedstrijdRelatedByThuisteam($wedstrijd, $comparison = null)
	{
		return $this
			->addUsingAlias(TeamPeer::TEAMID, $wedstrijd->getThuisteam(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the WedstrijdRelatedByThuisteam relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function joinWedstrijdRelatedByThuisteam($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('WedstrijdRelatedByThuisteam');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'WedstrijdRelatedByThuisteam');
		}
		
		return $this;
	}

	/**
	 * Use the WedstrijdRelatedByThuisteam relation Wedstrijd object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    WedstrijdQuery A secondary query class using the current class as primary query
	 */
	public function useWedstrijdRelatedByThuisteamQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinWedstrijdRelatedByThuisteam($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'WedstrijdRelatedByThuisteam', 'WedstrijdQuery');
	}

	/**
	 * Filter the query by a related Wedstrijd object
	 *
	 * @param     Wedstrijd $wedstrijd  the related object to use as filter
	 * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function filterByWedstrijdRelatedByUitteam($wedstrijd, $comparison = null)
	{
		return $this
			->addUsingAlias(TeamPeer::TEAMID, $wedstrijd->getUitteam(), $comparison);
	}

	/**
	 * Adds a JOIN clause to the query using the WedstrijdRelatedByUitteam relation
	 * 
	 * @param     string $relationAlias optional alias for the relation
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function joinWedstrijdRelatedByUitteam($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		$tableMap = $this->getTableMap();
		$relationMap = $tableMap->getRelation('WedstrijdRelatedByUitteam');
		
		// create a ModelJoin object for this join
		$join = new ModelJoin();
		$join->setJoinType($joinType);
		$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
		if ($previousJoin = $this->getPreviousJoin()) {
			$join->setPreviousJoin($previousJoin);
		}
		
		// add the ModelJoin to the current object
		if($relationAlias) {
			$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
			$this->addJoinObject($join, $relationAlias);
		} else {
			$this->addJoinObject($join, 'WedstrijdRelatedByUitteam');
		}
		
		return $this;
	}

	/**
	 * Use the WedstrijdRelatedByUitteam relation Wedstrijd object
	 *
	 * @see       useQuery()
	 * 
	 * @param     string $relationAlias optional alias for the relation,
	 *                                   to be used as main alias in the secondary query
	 * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
	 *
	 * @return    WedstrijdQuery A secondary query class using the current class as primary query
	 */
	public function useWedstrijdRelatedByUitteamQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
	{
		return $this
			->joinWedstrijdRelatedByUitteam($relationAlias, $joinType)
			->useQuery($relationAlias ? $relationAlias : 'WedstrijdRelatedByUitteam', 'WedstrijdQuery');
	}

	/**
	 * Exclude object from result
	 *
	 * @param     Team $team Object to remove from the list of results
	 *
	 * @return    TeamQuery The current query, for fluid interface
	 */
	public function prune($team = null)
	{
		if ($team) {
			$this->addUsingAlias(TeamPeer::TEAMID, $team->getTeamid(), Criteria::NOT_EQUAL);
	  }
	  
		return $this;
	}

} // BaseTeamQuery
